<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Search extends CI_Controller {
	
	

		
	public function index(){
		$this->load->helper('form');
		$this->load->helper('date');
		$this->load->library('session');
		$this->load->library('form_validation');
		$this->form_validation->set_rules('from','from', 'required');
		$this->form_validation->set_rules('to','to', 'required');
		$this->form_validation->set_rules('year','year');
		$this->form_validation->set_rules('month','month');
		$this->form_validation->set_rules('day','day');
		$this->form_validation->set_rules('time','time');
		if($this->form_validation->run() == FALSE){
			
			$this->load->view('search_view1');
		
		} else {
			
			$from = $this->input->post('from');
			$to = $this->input->post('to');
			$this->load->model('search_model');
			$data['result'] = $this->search_model->search_trip($from,$to);
			$this->load->view('search_view2', $data);
		}
	}
}
?>